//放大镜
let fdjimg = document.querySelector('.fdj-img');
let fdjcusor = document.querySelector('.fdj-cusor');
let showbox = document.querySelector('.fdj-show');
let fdjshow = document.querySelector('.fdj-show>img');

fdjimg.onmouseover = function () {
    fdjcusor.style.display = 'block'
    showbox.style.display = 'block'
}
fdjimg.onmouseout = function () {
    fdjcusor.style.display = 'none'
    showbox.style.display = 'none'
}
fdjimg.onmousemove = function (e) {
    var e = e || window.event
    var x = e.pageX - 250
    var y = e.pageY - 300
    if (x >= 250) {
        x = 250
    }
    if (x < 0) {
        x = 0
    }
    if (y >= 250) {
        y = 250
    }
    if (y <= 0) {
        y = 0
    }
    fdjcusor.style.left = x + 'px'
    fdjcusor.style.top = y + 'px'

    fdjshow.style.left = -x + 'px'
    fdjshow.style.top = -y + 'px'
}

//商品数目加购
let numInput = document.querySelector('.numinput')
let numup = document.querySelector('.shop-num>a')
let numout = document.querySelector('.shop-num>i')
let shopnum = 1;
numup.onclick = function () {
    ++shopnum;
    numInput.value = shopnum;
    return shopnum;
}
numout.onclick = function () {
    --shopnum;
    if (shopnum < 1) {
        shopnum = 1
    }
    numInput.value = shopnum;
    return shopnum;

}


//加入购物车
let gwcBtn = document.querySelector('.shop-car');
window.onload = function () {
    gwcBtn.onclick = function () {
        location.replace("./buycar.html")
    }
}

let buyca = document.querySelector('.buyCa');
buyca.onclick = function(){
  location.assign("./buycar.html")
}